#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
using namespace std;

int main() {
    int n = 0;
    while (cin >> n) {
        cerr << "n=" << n << endl;
        int x = 2;
        int i = 0;
        while (i < n) {
            //cout<<x<<" ";
            i += x;
            x *= 2;
        }
        //cout<<endl;
        cerr << (x / 2) - 1 << endl;
        cout << (x / 2) - 1 << endl;
    }
}
